package com.ruoyi.project.app.controller;

import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.project.app.entity.SmsEntity;
import com.ruoyi.project.constant.statuEnum.SmsTypeEnum;
import com.ruoyi.project.mq.MqSender;
import netscape.javascript.JSObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 *  @author hry
 * 测试通过RabbitMQ  发送消息
 */
@RestController
@RequestMapping("/front/mq")
public class TestmqController {

    public MqSender mqSender = SpringUtils.getBean(MqSender.class);

    @GetMapping("/{phone}")
    public void sendSms(@PathVariable("phone") String phone) throws Exception{

        JSONObject map = new JSONObject();
        map.put("code","66666");

        //给用户发短信,提示登录成功
        SmsEntity smsEntity = new SmsEntity();
        smsEntity.setJsonObject(map);
        smsEntity.setPhone(phone);
        smsEntity.setSmsTypeEnum(SmsTypeEnum.LOGIN);
        mqSender.smsSend(smsEntity);
    }

}
